package cn.life.common.entity.model;

import java.io.Serializable;

public class CMessage implements Serializable {
    /**
     * 状态位
     */
    private String code;
    /**
     * 提示信息
     */
    private String msg;
    /**
     * 数据集合
     */
    private Object data;

    public CMessage() {
    }

    public CMessage(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }


    public static CMessage success() {
        return new CMessage(CMessageCode.SUCCESS, "成功", null);
    }

    public static CMessage registerSuccess() {
        return successByMsg("注册成功");
    }

    public static CMessage addSuccess() {
        return successByMsg("添加成功");
    }

    public static CMessage modifySuccess() {
        return successByMsg("修改成功");
    }

    public static CMessage removeSuccess() {
        return successByMsg("删除成功");
    }

    public static CMessage addFail() {
        return fail("添加失败");
    }

    public static CMessage modifyFail() {
        return fail("修改失败");
    }

    public static CMessage removeFail() {
        return fail("删除失败");
    }

    public static CMessage successByMsg(String msg) {
        return new CMessage(CMessageCode.SUCCESS, msg, null);
    }

    public static CMessage successByData(Object data) {
        return new CMessage(CMessageCode.SUCCESS, "成功", data);
    }

    public static CMessage success(String msg, Object data) {
        return new CMessage(CMessageCode.SUCCESS, msg, data);
    }

    public static CMessage fail(String msg) {
        return new CMessage(CMessageCode.FAIL, msg, null);
    }

    public static CMessage fail(String code, String msg) {
        return new CMessage(code, msg, null);
    }

    public static CMessage fail(String code, String msg, Object data) {
        return new CMessage(code, msg, data);
    }

}